<template>
  <div class="sousuo">
    <div class="sousuo-ipt">
      <img @click="back()" class="back" src="../../assets/img/shouye/header-xinpin/back.png"/>
      <div>
        <img class="sousuo-img" src="../../assets/img/shouye/shouye/sousuo.png" height="30" width="28"/>
        <input type="text" placeholder="输入商品关键词">
      </div>
      <router-link :to="{name: 'sousuo-jieguo'}">
        <span class="router-sousuo">搜索</span>
      </router-link>
    </div>
    <h3>亲们都在找</h3>
    <div class="sousuo-list">
      <ul class="list-ul">
        <li>
          <ul class="list-ul-ul">
            <li><p>面膜</p></li>
            <li><p>防晒</p></li>
            <li><p>眼霜</p></li>
            <li><p>精华</p></li>
          </ul>
        </li>
        <li>
          <ul class="list-ul-ul">
            <li><p>洗面奶</p></li>
            <li><p>资生堂</p></li>
            <li><p>洗发水</p></li>
            <li><p>防晒喷雾</p></li>
          </ul>
        </li>
        <li>
          <ul class="list-ul-ul">
            <li><p>洗面奶</p></li>
            <li><p>资生堂</p></li>
            <li><p>洗发水</p></li>
            <li><p>防晒喷雾</p></li>
          </ul>
        </li>
      </ul>
    </div>
    <h3>最近搜索</h3>
    <div class="zuijinss">
      <ul v-if="isDel">
        <li>睫毛膏</li>
        <li>睫毛膏</li>
      </ul>
      <p @click="historyDel()">清空搜索历史</p>
    </div>
    <div class="up" @click="toTop()" v-if="isUP">
      <img src="../../assets/img/shouye/tuijian-xuanliyanzhuang/toTop.png"/>
    </div>
  </div>
</template>
<script scoped>
  export default {
    data () {
      return {
        isDel: true,
        isUP: false
      }
    },
    methods: {
      historyDel () {
        this.isDel = false
      },
      back () {
        this.$router.go(-1)
      },
      toTop () {
        if(document.documentElement){
          document.documentElement.scrollTop = 0;
        }else{
          document.body.scrollTop = 0;
        }
      },
      menu() {
        this.scroll = document.documentElement.scrollTop || document.body.scrollTop;
        if(this.scroll > 0){
          //显示 a 标签
          this.isUP = true;
        }else{
          //隐藏 a 标签
          this.isUP = false;
        }
      },
      top () {
        window.scrollTo(0,0)
      }
    },
    mounted() {
      window.addEventListener('scroll', this.menu)
    },
    created () {
      this.top();
    }
  }
</script>
<style scoped>
  .sousuo {
    background: #f2f2f2;
    /*height: 30rem;*/
    width: 100%;
    padding-top: 2rem;
    position: relative;
  }
  .back {
    vertical-align: middle;
    width: 0.6rem;
    height: 1rem;
    margin: 0.6rem 0.6rem 0 0.5rem;
  }
  .sousuo .sousuo-ipt{
    height: 2rem;
    background: #e53e42;
    display: flex;
    text-align: center;
    line-height: 2rem;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10;
  }
  .sousuo .sousuo-ipt .router-span,.sousuo .router-sousuo {
    font-size: 0.8rem;
    margin: 0 0.5rem;
    color: #ffffff;
  }
  .sousuo .router-sousuo {
    margin-left: 2.2rem;
  }
  .sousuo .sousuo-ipt input {
    width: 10rem;
    height: 1rem;
    background-color: #ffffff;
    border-radius: 0.3rem;
    margin-top: 0.4rem;
    margin-left: 0.5rem;
    padding-left: 0.9rem;
  }
  .sousuo  .sousuo-ipt div{
    position: relative;
    width: 10rem;
    height: 1rem;
  }
  .sousuo .sousuo-ipt .sousuo-img {
    width: 0.7rem;
    height: 0.7rem;
    position: absolute;
    top: 0.8rem;
    left: 0.8rem;
  }
  .sousuo>h3{
    font-family: MicrosoftYaHei;
    font-size: 0.8rem;
    font-weight: normal;
    font-stretch: normal;
    line-height: 2rem;
    letter-spacing: 0rem;
    color: #808080;
    padding: 0 0.5rem;
  }
  .sousuo-list {
  }
  .sousuo .list-ul {
    background: #fff;
    padding: 0 0.5rem 0 0;
    padding-bottom: 2rem;
  }
  .sousuo .list-ul-ul {
    display: flex;
  }
  .sousuo .list-ul-ul li {
    flex: 1;
    font-family: MicrosoftYaHei;
    font-size: 0.6rem;
    font-weight: normal;
    font-stretch: normal;
    line-height: 2rem;
    letter-spacing: 0rem;
    color: #4d4d4d;
    margin-left:  0.5rem;
  }
  .sousuo .list-ul-ul li p{
    height: 50%;
    line-height: 150%;
    margin-top: 25%;
    text-align: center;
    border-radius: 1rem;
    border: solid 1px #cccccc;
  }
  .zuijinss{
    background: #fff;
  }
  .zuijinss ul li {
    font-family: MicrosoftYaHei;
    font-size: 0.6rem;
    font-weight: normal;
    font-stretch: normal;
    line-height: 1.5rem;
    letter-spacing: 0rem;
    color: #4d4d4d;
    padding-left:  0.5rem;
    border-bottom: 1px solid #ccc;
  }
  .zuijinss p {
    width: 6rem;
    display: block;
    text-align: center;
    margin: 0.5rem auto;
    padding: 0.1rem;
    border: 1px solid #cccccc;
    border-radius: 0.6rem;
    font-family: MicrosoftYaHei;
    font-size: 0.6rem;
    font-weight: normal;
    letter-spacing: 0rem;
    color: #808080;
  }
  .sousuo-ipt input::placeholder{
    font-size: 0.6rem;
    color: #e83d41;
  }
  .up {
    width: 1.5rem;
    position: fixed;
    bottom: 0;
    right: 0.3rem;
  }
  .up img {
    width: 100%;
  }
</style>
